package edu.bbu.commonproject.desktop.gui.view.swing.utils;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JButton;

/**
 * The transparent button class.
 */
public class TransparentButton extends JButton
{
	/**
	 * The constructor.
	 */
	public TransparentButton()
	{
		super();
		setTransparent();
	}
	
	/**
	 * The constructor.
	 * @param text the text name.
	 */
	public TransparentButton(String text)
	{
		super(text);
		setTransparent();
	}
	
	/**
	 * Sets the transparency of the button.
	 */
	private void setTransparent()
	{
		setContentAreaFilled(false);
		setOpaque(false);
		
		this.addMouseListener(new MouseAdapter()
		{
			public void mouseEntered(MouseEvent e)
			{
				setContentAreaFilled(true);
				setOpaque(false);
			}
			
			public void mouseExited(MouseEvent e)
			{
				setContentAreaFilled(false);
				setOpaque(false);
			}
		});
	}

}
